package IC.AST.nodes;

import IC.AST.*;

/**
 * a variable declaration statement
 */
public class VarDeclStmt extends Statement {
	private TypeDecl type;	// the variable type
	private SimpleVar var;	// the variable
	private Expression init;	// the initiallization (may be null)

	/**
	 * @param type the variable type
	 * @param id the variable name
	 * @param init the initiallization (may be null)
	 * @param fileName TODO
	 * @param line the node line number
	 * @param column the node column number
	 */
	public VarDeclStmt(TypeDecl type, SimpleVar var, Expression init, String fileName, int line, int column) {
		super(fileName, line,column);
		this.type = type;
		this.var = var;
		this.init = init;
	}

	/**
	 * @return the variable type
	 */
	public TypeDecl getType() {
		return this.type;
	}

	/**
	 * @return the variable name
	 */
	public SimpleVar getVar() {
		return this.var;
	}

	/**
	 * @return the initiallization (may be null)
	 */
	public Expression getInit() {
		return this.init;
	}

	public <D,U> U accept(PropogatingVisitor<D,U> v, D context) throws Exception {
		return v.visit(this,context);
	}
}
